<?php
class creat_qrcode {
	public function creategroupQrcode($mid = 0) {		
		global $_W, $_GPC;
		$path = IA_ROOT . "/attachment/lexiangpingou/qrcode/" . $_W['uniacid'] . "/";
		$path2 = IA_ROOT . "/addons/lexiangpingou/data/qrcode/" . $_W['uniacid'] . "/";
		$path3 = IA_ROOT . "/addons/lexiangpingou/data/pcqrcode/" . $_W['uniacid'] . "/";
		if (!is_dir($path)) {
			load() -> func('file');
			mkdirs($path);
		}
		if (!is_dir($path2)) {
			load() -> func('file');
			mkdirs($path2);
		} 
		if (!is_dir($path3)) {
			load() -> func('file');
			mkdirs($path3);
		}
		$roots="http://".$_SERVER['HTTP_HOST']."/";
		$url = $roots . 'app/index.php?i=' . $_W['uniacid'] . '&c=entry&m=lexiangpingou&do=order&ac=check&mid=' . $mid;
		$file = $mid . '.png';
		$qrcode_file = $path . $file;
		$qrcode_file2 = $path2 . $file;
		$qrcode_file3 = $path3 . $file;
		if (!is_file($qrcode_file2)) {
			require IA_ROOT . '/framework/library/qrcode/phpqrcode.php';
			QRcode :: png($url, $qrcode_file, QR_ECLEVEL_H, 4);
			QRcode :: png($url, $qrcode_file2, QR_ECLEVEL_H, 4);
			QRcode :: png($mid, $qrcode_file3, QR_ECLEVEL_H, 4);
		} 
		return $roots. 'addons/lexiangpingou/data/qrcode/' . $_W['uniacid'] . '/' . $file;
	
	}
	public function creategroupQrcodes($mid = 0) {
		global $_W, $_GPC;
		$path = IA_ROOT . "/attachment/lexiangpingou/qrcode/" . $_W['uniacid'] . "/";
		$path2 = IA_ROOT . "/addons/lexiangpingou/data/qrcode/" . $_W['uniacid'] . "/";
		$path3 = IA_ROOT . "/addons/lexiangpingou/data/pcqrcode/" . $_W['uniacid'] . "/";
		if (!is_dir($path)) {
			load() -> func('file');
			mkdirs($path);
		}
		if (!is_dir($path2)) {
			load() -> func('file');
			mkdirs($path2);
		}
		if (!is_dir($path3)) {
			load() -> func('file');
			mkdirs($path3);
		}
		$roots="http://".$_SERVER['HTTP_HOST']."/";
		$url = $roots . 'app/index.php?i=' . $_W['uniacid'] . '&c=entry&m=lexiangpingou&do=order&ac=check&mid=' . $mid;
		$file = $mid . '.png';
		$qrcode_file = $path . $file;
		$qrcode_file2 = $path2 . $file;
		$qrcode_file3 = $path3 . $file;
		if (!is_file($qrcode_file2)) {
			require IA_ROOT . '/framework/library/qrcode/phpqrcode.php';
			QRcode :: png($url, $qrcode_file, QR_ECLEVEL_H, 4);
			QRcode :: png($url, $qrcode_file2, QR_ECLEVEL_H, 4);
			QRcode :: png($mid, $qrcode_file3, QR_ECLEVEL_H, 4);
		}
		return $roots. 'addons/lexiangpingou/data/qrcode/' . $_W['uniacid'] . '/' . $file;

	}
	public function createshaoniangongQrcode($mid = 0) {

		global $_W, $_GPC;

		$path = IA_ROOT . "/attachment/lexiangpingou/qrcode/" . $_W['uniacid'] . "/";
		$path2 = IA_ROOT . "/addons/lexiangpingou/data/qrcode/" . $_W['uniacid'] . "/";
		$path3 = IA_ROOT . "/addons/lexiangpingou/data/pcqrcode/" . $_W['uniacid'] . "/";
		if (!is_dir($path)) {
			load() -> func('file');
			mkdirs($path);
		}
		if (!is_dir($path2)) {
			load() -> func('file');
			mkdirs($path2);
		}
		if (!is_dir($path3)) {
			load() -> func('file');
			mkdirs($path3);
		}

		$roots="http://".$_SERVER['HTTP_HOST']."/";
		$url = $roots . 'app/index.php?i=' . $_W['uniacid'] . '&c=entry&m=lexiangpingou&do=order&ac=shaoniancheck&mid=' . $mid;
		$file = $mid . '.png';
		$qrcode_file = $path . $file;
		$qrcode_file2 = $path2 . $file;
		$qrcode_file3 = $path3 . $file;
		if (!is_file($qrcode_file2)) {
			require IA_ROOT . '/framework/library/qrcode/phpqrcode.php';
			QRcode :: png($url, $qrcode_file, QR_ECLEVEL_H, 4);
			QRcode :: png($url, $qrcode_file2, QR_ECLEVEL_H, 4);
			QRcode :: png($mid, $qrcode_file3, QR_ECLEVEL_H, 4);
		}
		return $roots. 'addons/lexiangpingou/data/qrcode/' . $_W['uniacid'] . '/' . $file;
	}

	public function createverQrcode($mid = 0 , $goodsid = 0, $posterid = 0) {
		global $_W, $_GPC;
		$path = IA_ROOT . "/addons/lexiangpingou/qrcode/" . $_W['uniacid'];
		if (!is_dir($path)) {
			load() -> func('file');
			mkdirs($path);
		} 
		$roots='w9.huodiesoft.com';
		if($_W['uniacid']!=53)
		{
			$roots='www.lexiangpingou.cn';
		}
		
		if($_W['uniacid']==33)
		{
			$roots = "http://".$roots."/";
		}else{
			$roots = "http://".$_W['uniaccount']['key'].".".$roots."/";
		}
		$url = $_W['siteroot'] . 'app/index.php?i=' . $_W['uniacid'] . '&c=entry&m=lexiangpingou&do=shop&p=detail&id=' . $goodsid . '&mid=' . $mid;
		if (!empty($posterid)) {
			$url .= '&posterid=' . $posterid;
		} 
		$file = 'ver_qrcode_' . $posterid . '_' . $mid . '_' . $goodsid . '.png';
		$qrcode_file = $path . '/' . $file;
		if (!is_file($qrcode_file)) {
			require IA_ROOT . '/framework/library/qrcode/phpqrcode.php';
			QRcode :: png($url, $qrcode_file, QR_ECLEVEL_H, 4);
		} 
		return $roots . 'addons/lexiangpingou/qrcode/' . $_W['uniacid'] . '/' . $file;
	} 
	public function createfunctionpayQrcode($functionid = 0 , $num = 0, $orderno = 0,$uniacid=0) {
		global $_W, $_GPC;
		$uniacid=33;
		$path = IA_ROOT . "/addons/lexiangpingou/qrcode/" . $uniacid;
		$path2 = IA_ROOT . "/addons/lexiangpingou/data/qrcode/" . $uniacid . "/";
		if (!is_dir($path)) {
			load() -> func('file');
			mkdirs($path);
		} 
		if (!is_dir($path2)) {
			load() -> func('file');
			mkdirs($path2);
		}
		$roots='w9.huodiesoft.com';
		if($_W['uniacid']!=53)
		{
			$roots='www.lexiangpingou.cn';
		}
		
		if($_W['uniacid']==33)
		{
			$roots = "http://".$roots."/";
		}else{
			$roots = "http://".$_W['uniaccount']['key'].".".$roots."/";
		}
		$url = $_W['siteroot']. 'app/index.php?i=' . $uniacid . '&c=entry&m=lexiangpingou&do=pay&ac=payfunction&id=' . $functionid;
		$url .= '&num=' . $num;
		$url .= '&buyuniacid=' . $_W['uniacid'];
		$url .= '&orderno=' . $orderno;
		$file =  $orderno . '.png';
		$qrcode_file = $path . $file;
		$qrcode_file2 = $path2 . $file;
		if (!is_file($qrcode_file)) {
			require IA_ROOT . '/framework/library/qrcode/phpqrcode.php';
		
			QRcode :: png($url, $qrcode_file2, QR_ECLEVEL_H, 4);
		} 
		
		//return $_W['siteroot'] . 'addons/lexiangpingou/qrcode/' . $uniacid . '/' . $file;
		return $roots . 'addons/lexiangpingou/data/qrcode/' . $uniacid . '/' . $file;
	} 
} 
